<div class="header">
    <ul class="layui-nav layui-layout-left">
        <li class="layui-nav-item">
            <a href="JavaScript:;">计算机一级</a>
            <dl id="typeTest" class="layui-nav-child">
                <dd><a href="javascript:;" mysort="1" >计算机一级</a></dd>
                <dd><a href="javascript:;" mysort="2" >计算机二级</a></dd>
            </dl>
        </li>
		<!--
        <li class="layui-nav-item">
            <a href="">错题练习</a>
        </li>
        -->
        <li class="layui-nav-item"><a id="mockexam">模拟考试</a></li>
        <li class="layui-nav-item">
        	
            <a href="javascript:;">专项练习</a>
            <dl class="layui-nav-child option">
                <dd class="nicety-item" nicetyType="choice"><a href="javascript:;">选择题</a></dd>
                <dd class="nicety-item" nicetyType="word"><a href="javascript:;">Wrod</a></dd>
                <dd class="nicety-item" nicetyType="excel"><a href="javascript:;">Excel</a></dd>
                <dd class="nicety-item" nicetyType="ppt"><a href="javascript:;">PowerPoint</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item"><a href="${rootUrl}/exam">开始考试</a></li>
    </ul>
    <ul class="layui-nav layui-layout-right">
    	<li class="layui-nav-item"><a href="myInfo">${user.name!'无名氏'}</a></li>
        <li class="layui-nav-item">
            <a href="javascript:;">个人中心</a>
            <dl class="layui-nav-child">
                <dd><a href="${rootUrl}/myInfo">查看资料</a></dd>
                <dd><a href="${rootUrl}/logout">退出</a></dd>
            </dl>
        </li> 
    </ul>
</div>
<script src="${staticUrl}/plugins/jquery/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="${staticUrl}/plugins/layui/layui.all.js" type="text/javascript"></script>
	<script type="text/javascript">
		var	staticUrl = '${staticUrl}';
		var	rootUrl = '${rootUrl}';
		var paperType = localStorage.paperType
		console.log('ls paperType:'+paperType)
		if(! paperType){
			paperType = 1
		}
		function updatePaperType(curr){
			paperType = curr
			localStorage.paperType = curr
			var type = '';
			$("#typeTest dd a").each(function () {
	            if($(this).attr("mysort")==curr){
	                $(this).parent().addClass("layui-this");
	                type = $(this).text();
	            }
        	})
        	$("#typeTest").prev().text(type);
        	$("#typeTest").prev().append("<span class='layui-nav-more'></span>");
		}
		
		updatePaperType(paperType)
		$("#typeTest dd a").on("click",function () {
		    var id = $(this).attr("mysort");
		    updatePaperType(id)
		})

		$('.nicety-item').on('click',function(e){
			var target = e.currentTarget
			var type = $(target).attr('nicetyType')
			window.location.href= rootUrl + '/mockExam?paper=' + paperType +'&type='+type
		});
		$('#mockexam').on('click',function(e){
			window.location.href= rootUrl + '/mockExam?paper=' + paperType
		})
</script>